Skip to content

ContextHelper::is_in_array_comparison(): add basic tests#2726

Merged
jrfnl merged 2 commits intodevelopfrom
is-in-array-comparison-tests
Apr 27, 2026
Merged

ContextHelper::is_in_array_comparison(): add basic tests#2726
jrfnl merged 2 commits intodevelopfrom
is-in-array-comparison-tests

Conversation

@rodrigoprimo
Copy link
Copy Markdown
Collaborator

Description

In preparation for supporting PHPCS 4.0, this PR adds unit tests for the ContextHelper::is_in_array_comparison() method.

Suggested changelog entry

N/A

@rodrigoprimo
Copy link
Copy Markdown
Collaborator Author

I added a new commit with a negative bare variable test as suggested in #2725 (review) for consistency.

@jrfnl jrfnl added this to the 3.4.0 milestone Apr 27, 2026
@jrfnl jrfnl force-pushed the is-in-array-comparison-tests branch from 9ccc62d to 94dfbaa Compare April 27, 2026 12:42
Copy link
Copy Markdown
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rodrigoprimo ! Looking good again.

One thing I would like to point out - but not a blocker -: these helper functions generally can target any arbitrary token to check if that token is "in an array comparison" or "in isset".

All the tests specifically target variables though, which makes them a little one-dimensional (but doesn't take anything away from the value of having those tests). Having some variation - a test targetting a T_COMMA or a T_STRING function call or constant or something, would also document better that the functions can be used on any type of token.

@jrfnl jrfnl merged commit 22d4758 into develop Apr 27, 2026
42 checks passed
@jrfnl jrfnl deleted the is-in-array-comparison-tests branch April 27, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants